package multiple.thread.copy;

import java.io.File;

public class ExpressCopy {
	  
    private String sourceFilePath;//源文件路径  
    private String desFilePath;//目标文件路径  
    public ExpressCopy(String sourceFilePath,String desFilePath)  
    {   
        this.sourceFilePath=sourceFilePath;  
        this.desFilePath=desFilePath;  
    }  
    public  void work()  
    {  
        File f=new File(sourceFilePath);   
        if(!f.exists()||f.length()==0)  
        {  
            System.out.println("The source file"+sourceFilePath+"does not exist or its length is 0");  
        }  
        long len=f.length();  
        try  
        {  
             Thread[] t=new Thread[2];  
             for(int i=0;i<2;i++)          //控制产生几个线程
             {  
                 t[i]=new WorkThread(i*len/2,(i+1)*len/2,sourceFilePath,desFilePath);  
                 System.out.println("第"+i+"个线程已经启动");  
                 t[i].start();  
             }  
        }catch(Exception e)  
        {  
            e.printStackTrace();  
        }     
    }  
    
    public static void main(String[] args) {
    	ExpressCopy expressCopy=new ExpressCopy("Penguins.jpg", "D:/Lionel/workspace/homework_Wendsday/Penguins1.jpg");
    	expressCopy.work();
	}

}
